import {useState} from "react"

import {createContext,useContext} from "react"

const aa  = createContext()

export function MyDeep(){
    const [Msg,setMsg] = useState("CHINA")
    return (
        <div>

            <aa.Provider value={Msg}>
                <h2>这是一个组件</h2>
            </aa.Provider>
            <h2>====</h2>
            <A></A>
        </div>
    )
}

function A(){
    return (
        <div>
            我是A
            <B></B>
        </div>
    )
}

function B(){
    const Msg = useContext(aa)
    return (
        <div>
            我是B---{Msg}
        </div>
    )
}